﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Collections;
using System.Collections.Specialized;

namespace UMC.Web
{
    /// <summary>
    /// 确定提示框
    /// </summary>
    public class UIConfirmDialog : UIDialog
    {
        public UIConfirmDialog(string text)
        {
            this.Title = "提示";
            this.Config["Text"] = text;
            this.Config["DefaultValue"] = "OK";
        }

        public UIConfirmDialog Action(UIClick value)
        {
            this.Config.Put("Action", value);
            return this;
        }
        public UIConfirmDialog Action(bool value)
        {
            if (value)
            {

                this.Config.Put("Action", true);
            }
            else
            {

                this.Config.Remove("Action");//, true);
            }
            return this;

        }
        public UIConfirmDialog(string text, string defaultValue)
        {
            this.Config["Text"] = text;
            this.DefaultValue = defaultValue;
        }
        public bool IsCancel
        {
            get
            {
                return this.Config.ContainsKey("IsCancel");
            }
            set
            {

                if (value)
                {
                    this.Config.Put("IsCancel", true);
                }
                else
                {

                    this.Config.Remove("IsCancel");//,true);
                }
            }
        }
        public string CancelText
        {
            get; set;
        }
        protected override string DialogType
        {
            get { return "Confirm"; }
        }
        protected override void Initialization(WebContext context)
        {
            if (String.IsNullOrEmpty(CancelText) == false)
            {
                this.Config.Put("Cancel", CancelText);
            }
            this.Config["DefaultValue"] = this.DefaultValue ?? "OK";
            base.Initialization(context);
        }
    }
}
